package com.zzzy.service;


import com.zzzy.config.DataSource;
import com.zzzy.mapper.UserMapper;
import com.zzzy.po.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service

public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    @DataSource
    public User findUser(int id) {
        User user = userMapper.selectById(id);
        return user;
    }

    @Override
    @DataSource
    @Transactional(propagation=Propagation.REQUIRED)
    public void addUser(User user) {
        userMapper.insertUser(user);
    }
}
